package com.smedi.ismedi.constructionproject.core.port.adapter.persistence.repository.impl;

import com.smedi.ismedi.constructionproject.core.domain.aggregatemodel.File;
import com.smedi.ismedi.constructionproject.core.domain.dto.FileQuery;
import com.smedi.ismedi.constructionproject.core.domain.repository.FileRepository;
import com.smedi.ismedi.constructionproject.core.port.adapter.restful.convert.AdapterConverter;
import com.smedi.ismedi.constructionproject.core.port.adapter.service.FileRemoteService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @auther Cookie
 * @date 2022/7/20
 */
@Service
@AllArgsConstructor
public class FileRepositoryImpl implements FileRepository {
    private final AdapterConverter adapterConverter;

    private final FileRemoteService fileRemoteService;

    @Override
    public File getFileOne(FileQuery fileQuery) {
        return adapterConverter.fileInfoResponseToFile(fileRemoteService.getFileInfoOne(fileQuery));
    }

    @Override
    public List<File> getFileList(FileQuery fileQuery) {
        return adapterConverter.fileInfoResponseToFile(fileRemoteService.getFileInfoList(fileQuery));
    }
}
